 #include <iostream>
 #include <string>
 using namespace std;
 class Product{
	public:
		virtual void print() = 0;
 };
 
 class AProduct:public Product{
		string name;
	public:
		AProduct(const string& nm = ""):name(nm){
		}
		virtual void print(){
			cout << "AProduct:" << name << endl;
		}
 };
 
  class BProduct:public Product{
		string name;
	public:
		BProduct(const string& nm = ""):name(nm){
		}
		virtual void print(){
			cout << "BProduct:" << name << endl;
		}
 };
   class CProduct:public Product{
		string name;
	public:
		CProduct(const string& nm = ""):name(nm){
		}
		virtual void print(){
			cout << "CProduct:" << name << endl;
		}
 };
 
 class Factory{
	public:
		virtual Product* create(int type) = 0;
 };
 
 class AFactory:public Factory{
	public:
		virtual Product* create(int type);
 };
 
Product* AFactory::create(int type){
	if(type ==1)
		return new AProduct("AFactory");
	else if(type == 2)
		return new BProduct("BProduct");
	else
		return new CProduct("CProduct");
 }
 
 int main(){
	Factory *factory = new AFactory();
	Product *aproduct = factory->create(1);
	aproduct->print();
	return 0;
 }